import React, { Component } from 'react'
import {SELECT_ALL} from './store/types'
import {connect} from 'react-redux'
class Footer extends Component {
  render() {
    return (
      <div>
        <div>
          <input checked={this.props.isAll} onChange={(e)=>{
            this.props.changeAll(e.target.checked)
          }} type="checkbox" /> 全选
        </div>
        <span>
          {this.props.selectCount}/{this.props.todoList.length}
        </span>
      </div>
    )
  }
}


export default connect((state)=>{
  return {
    selectCount: state.todo.selectCount,
    isAll: state.todo.isAll,
    todoList: state.todo.todoList
  }
}, (dispatch)=>{
  return {
    changeAll(val){
      dispatch({type: SELECT_ALL, payload: val})
    }
  }
})(Footer)
